//
//  WholeAssessmentViewController.m
//  智云题库
//
//  Created by 毕武侠 on 2017/3/24.
//  Copyright © 2017年 bwx. All rights reserved.
//

#import "WholeAssessmentViewController.h"
#import "WholeAssessmentViewManager.h"
#import "WholeAssessmentModel.h"
#import "JiGuangUnit.h"


@interface WholeAssessmentViewController ()

@property (nonatomic, strong) WholeAssessmentViewManager *viewManager;
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topConstraint;

@end

@implementation WholeAssessmentViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self setupConfigureView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)setupConfigureView {
    self.automaticallyAdjustsScrollViewInsets=NO;
    if (kDevice_Is_iPhoneX) {
        self.topConstraint.constant = kNavigationBarHeight;
    }
    [self loadHeadView:@"综合评估" showLeftBtn:self.index == 0 ? NO : YES showRightBtn:YES leftImageName:@"左箭头-2" rightImageName:@"CourseDetailShareIcon" leftTitle:nil rightTitle:nil];
    self.scrollView.hidden = YES;
    self.viewManager = [[WholeAssessmentViewManager alloc] initWithView:self.scrollView];
    
    self.viewModel = [[BaseViewModel alloc] initWithUrl:@"Question/zhpg"];
    [self didViewModelWithCompletionBlock:^(id receive) {
        self.scrollView.hidden = NO;
    }];
    
    self.viewManager.dataSignal = self.viewModel.command.executionSignals.switchToLatest;
    [self.viewModel.command execute:@"WholeAssessmentModel"];
    
    // 添加刷新页面数据通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateViewNotication:) name:@"UpdateUserAnswerNotification" object:nil];
}
- (void)headRightAction{
//    JSHAREMessage *message = [JSHAREMessage message];
//    message.mediaType = JSHARELink;
//    NSDictionary *dic = @{@"share_type":@"10"};
//    [[JiGuangUnit sharedInstant] shareViewAddSubview:self.view withMessage:message andDic:dic];
}
#pragma mark - NSNotificationCenter
- (void)updateViewNotication:(NSNotification*)notification {
    [self.viewModel.command execute:@"WholeAssessmentModel"];
}



@end
